﻿Imports System.Data
Imports FirebirdSql.Data
Imports FirebirdSql.Data.FirebirdClient
Public Class _empregador
    Inherits _DataBase
    Private _idEmpregador As Integer
    Public Property idEmpregador() As Integer
        Get
            Return _idEmpregador
        End Get
        Set(ByVal value As Integer)
            _idEmpregador = value
        End Set
    End Property
    Private _nmEmpresa As String
    Public Property nmEmpresa() As String
        Get
            Return _nmEmpresa
        End Get
        Set(ByVal value As String)
            _nmEmpresa = value
        End Set
    End Property
    Private _edCompleto As String
    Public Property edCompleto() As String
        Get
            Return _edCompleto
        End Get
        Set(ByVal value As String)
            _edCompleto = value
        End Set
    End Property
    Private _nmProprietario As String
    Public Property nmProprietario() As String
        Get
            Return _nmProprietario
        End Get
        Set(ByVal value As String)
            _nmProprietario = value
        End Set
    End Property
    Private _nuTelefone1 As String
    Public Property nuTelefone1() As String
        Get
            Return _nuTelefone1
        End Get
        Set(ByVal value As String)
            _nuTelefone1 = value
        End Set
    End Property
    Private _nuTelefone2 As String
    Public Property nuTelefone2() As String
        Get
            Return _nuTelefone2
        End Get
        Set(ByVal value As String)
            _nuTelefone2 = value
        End Set
    End Property
    Private _nuTelefone3 As String
    Public Property nutelefone3() As String
        Get
            Return _nuTelefone3
        End Get
        Set(ByVal value As String)
            _nuTelefone3 = value
        End Set
    End Property
    Private _nuCEICNPJ As String
    Public Property nuCEICNPJ() As String
        Get
            Return _nuCEICNPJ
        End Get
        Set(ByVal value As String)
            _nuCEICNPJ = value
        End Set
    End Property
    Private _nmContato As String
    Public Property nmContato() As String
        Get
            Return _nmContato
        End Get
        Set(ByVal value As String)
            _nmContato = value
        End Set
    End Property
    Private _emContato As String
    Public Property emContato() As String
        Get
            Return _emContato
        End Get
        Set(ByVal value As String)
            _emContato = value
        End Set
    End Property

    Public Function insereEmpresa() As Integer
        conectaDb()
        insereEmpresa = execSQL(montaParametrosSQL("SP_EMPREGADOR_CMD", "INSERIR"))
        desconectaDb()

    End Function

    Public Sub alteraEmpresa(ByVal pIdEmpregador As Integer)
        idEmpregador = pIdEmpregador
        conectaDb()
        execSQLSemRetorno(montaParametrosSQL("SP_EMPREGADOR_CMD", "ALTERAR"))
        desconectaDb()
    End Sub

    Public Function consultaEmpregadores() As DataSet
        conectaDb()
        consultaEmpregadores = retornaDataSet(montaParametrosSQL("SP_EMPREGADOR_CONSULTA", "RESUMIDO"))
        desconectaDb()
    End Function

    Public Function consultaEmpregadorPorId(ByVal pIdEmpregador As Integer) As Boolean
        idEmpregador = pIdEmpregador
        conectaDb()
        dr = retornaDataReader(montaParametrosSQL("SP_EMPREGADOR_CONSULTA", "ID"))
        With dr
            If .Read Then
                nmEmpresa = .Item("O_NM_EMPRESA").ToString
                edCompleto = .Item("O_ED_COMPLETO").ToString
                nmProprietario = .Item("O_NM_PROPRIETARIO").ToString
                nuTelefone1 = .Item("O_NU_TELEFONE1").ToString
                nuTelefone2 = .Item("O_NU_TELEFONE2").ToString
                nutelefone3 = .Item("O_NU_TELEFONE3").ToString
                nuCEICNPJ = .Item("O_NU_CEICNPJ").ToString
                nmContato = .Item("O_NM_CONTATO").ToString
                emContato = .Item("O_EM_CONTATO").ToString
            End If
        End With
        desconectaDb()

    End Function

    Private Function montaParametrosSQL(ByVal nomeSP As String, ByVal pModo As String) As FbCommand
        With cmd
            .CommandText = nomeSP
            With .Parameters
                .Clear()
                .Add("MODO", FbDbType.VarChar, 10).Value = pModo
                .Add("I_ID_EMPRESA", FbDbType.Integer).Value = idEmpregador
                .Add("I_NM_EMPRESA", FbDbType.VarChar, 80).Value = nmEmpresa
                .Add("I_ED_COMPLETO", FbDbType.VarChar, 80).Value = edCompleto
                .Add("I_NM_PROPRIETARIO", FbDbType.VarChar, 50).Value = nmProprietario
                .Add("I_NU_TELEFONE1", FbDbType.VarChar, 15).Value = nuTelefone1
                .Add("I_NU_TELEFONE2", FbDbType.VarChar, 15).Value = nuTelefone2
                .Add("I_NU_TELEFONE3", FbDbType.VarChar, 15).Value = nutelefone3
                .Add("I_NU_CEICNPJ", FbDbType.VarChar, 20).Value = nuCEICNPJ
                .Add("I_NM_CONTATO", FbDbType.VarChar, 80).Value = nmContato
                .Add("I_EM_CONTATO", FbDbType.VarChar, 80).Value = emContato
            End With
        End With
        Return cmd

    End Function

  

End Class
